<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>内容图片</title>
    <link rel="stylesheet" href="__ADMIN__/vendor/layui/css/layui.css">
</head>
<body style="padding:0 10px;">
<table class="layui-table">
    <colgroup>
        <col width="60">
        <col>
        <col width="100">
        <col width="60">
    </colgroup>
    <thead>
    <tr>
        <th>ID</th>
        <th>{$Think.lang.slt}</th>
        <th>{$Think.lang.sort}</th>
        <th>{$Think.lang.caoz}</th>
    </tr>
    </thead>
    <tbody>
    {volist name="images" id="vo"}
    <tr>
        <td>{$vo.id}</td>
        <td><img src="/{$vo.pic}" alt="" height="50"></td>
        <td><input type="text" name="sort" value="{$vo.sort}" id="{$vo.id}" onchange="changesort(this)" required lay-verify="required" class="layui-input"></td>
        <td><a href="{:url('admin/article/delpic')}" pid="{$vo.id}" class="layui-btn layui-btn-mini layui-btn-danger del">{$Think.lang.delete}</a></td>
    </tr>
    {/volist}
    </tbody>
</table>
<script src="__ADMIN__/vendor/js/jquery.js"></script>
<script src="__ADMIN__/vendor/layui/layui.js"></script>
<script>
    function changesort(obj){
        var id=$(obj).attr('id');
        var sort=$(obj).val();
        layui.use('layer', function(){
            $.post("{:url('admin/article/picsort')}",{id:id,sort:sort},function(res){
                    if(res.code==1){
                        layer.msg(res.msg,{icon:1});
                        location.reload();//刷新页面
                    }else{
                        layer.msg(res.msg,{icon:2});
                        location.reload();//刷新页面
                    }
               });
        });  
    }
     layui.use('layer', function(){
        var layer = layui.layer;
        $('.del').on('click',function () {
            var url=$(this).attr('href');
            var id=$(this).attr('pid');
            layer.confirm('确定要删除该图片吗?', {icon: 3, title:'温馨提示'}, function(index){
               
               $.post(url,{id:id},function(res){
                    if(res.code==1){
                        layer.msg(res.msg,{icon:1});
                        location.reload();//刷新页面
                    }else{
                        layer.msg(res.msg,{icon:2});
                        location.reload();//刷新页面
                    }
               });
                // location.href=url;
                
            });
            return false;
        })
    });
</script>
</body>
</html>